package com.itheima.reggie.util;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;

public class StateConverter implements Converter<Integer> {
    @Override
    public Class<Integer> supportJavaTypeKey() {
        return Integer.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return null;
    }

    @Override
    public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return null;
    }

    @Override
    public CellData<String> convertToExcelData(Integer integer, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        if (ObjectUtils.isNotEmpty(integer)) {
            return new CellData("");
        }
        String paymentMethod;
        switch (integer) {
            case 1:
                paymentMethod = "微信";
                break;
            case 2:
                paymentMethod = "支付宝";
                break;
            default:
                paymentMethod = "";
        }
        return new CellData<>(paymentMethod);
    }
}
